/**
 * Header actions
 * @constructor
 * @author neo   
*/
import { toast } from 'nc-lightapp-front';
import cardAction from '../../../actions/card';
export default class buttonAction extends cardAction {
	constructor(comp) {
		super(comp);
	}
	commentChange = (value) => {
		const { dispatch, psninfoApprove } = this.comp.props;
		const { maxlength, lang } = psninfoApprove;
		if (value.length > maxlength) {
			toast({ color: 'warning', content: `${lang['gx6008-000207']}${maxlength}${lang['gx6008-000208']}` });
			value = value.slice(0, maxlength);
		}
		dispatch({
			type: 'psninfoApprove/update',
			payload: {
				approveComment: value
			}
		});
	};
	cancel = (event) => {
		const { dispatch } = this.comp.props;
		dispatch({
			type: 'psninfoApprove/update',
			payload: {
				approveModalShow: false
			}
		});
	};
	passed = (event) => {
		const { action, props } = this.comp;
		const { dispatch } = props;
		dispatch({
			type: 'psninfoApprove/update',
			payload: {
				approveStatus: '1'
			}
		});
		setTimeout(() => {
			this.approve();
		}, 100);
	};
	failed = (event) => {
		const { action, props } = this.comp;
		const { dispatch } = props;
		dispatch({
			type: 'psninfoApprove/update',
			payload: {
				approveStatus: '2'
			}
		});
		setTimeout(() => {
			this.approve();
		}, 100);
	};
}
